package client.comm.commlib.dialog

import android.content.Context
import androidx.lifecycle.MutableLiveData
import client.comm.commlib.R
import client.comm.commlib.databinding.LayoutValidatepwddialogBinding
import client.comm.commlib.toast.toast
import client.tzstore.oo.dialog.CenterDialog

class ValidatePwdDialog(context: Context) : CenterDialog<LayoutValidatepwddialogBinding>(context) {
    var title: String = ""
    var cancleTxt: String = "取消"
    var okTxt: String = "确定"
    val pwd = MutableLiveData<String>()
    override fun getV(): Int {
        return R.layout.layout_validatepwddialog
    }

    var ok: ((pwd: String) -> Unit)? = null
    var cancle: (() -> Unit)? = null

    override fun postBinding() {
        binding.event = this
    }

    fun okClick() {
        if (pwd.value.isNullOrEmpty()) {
            toast("请输入密码")
            return
        }
        cancel()
        ok?.invoke(pwd.value!!)
    }

    fun cancleClick() {
        cancle?.invoke()
        cancel()
    }
}